package me.zk.practice1.hw;

import javax.xml.crypto.Data;
import java.util.Scanner;

public class HWBJJ31 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");

        String p = scanner.nextLine();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < s.length; i++) {
            if (isMatch(s[i],p)) {
                sb.append(i);
                if (i != s.length-1) {
                    sb.append(",");
                }
            }

        }
        System.out.println(sb);
    }
    
    public static boolean isMatch(String s, String p){
        int n = s.length();
        int m = p.length();
        //前多少的字符
        boolean[][] dp = new boolean[n+1][m+1];
        dp[0][0] = true;
        for (int i = 0; i <=n ; i++) {
            for (int j = 1; j <=m ; j++) {
                if (p.charAt(j-1) == '*') {
                    dp[i][j] = dp[i][j-2];
                    if (matches(s,p,i,j-1)) {
                        dp[i][j] = dp[i][j] ||dp[i-1][j];
                    }
                } else {
                    if (matches(s,p,i,j)) {
                        dp[i][j] = dp[i-1][j-1];
                    }
                }
            }
        }
        return dp[n][m];
    }
    public static boolean matches(String s,String p,int i,int j){
        if (i==0){
            return false;
        }
        if (p.charAt(j-1)=='.') {
            return true;
        }
        return s.charAt(i-1) ==p.charAt(j-1);

    }
}
